<script>
    //调用微信JS api 支付
    function jsApiCall()
    {
        WeixinJSBridge.invoke(
                'getBrandWCPayRequest',
                {$jsApiParameters},
                function(res){
                    WeixinJSBridge.log(res.err_msg);
                    if(res.err_msg == 'get_brand_wcpay_request:ok') {
                        window.location.href = '{:url("pay_ok", ["order_id" => $order_id, "order_price" => $order_price,"member_type" => $member_type, "type" => $type])}';
                    }
                    if(res.err_msg != 'get_brand_wcpay_request:ok') {
                        $('#loadingToast').fadeOut(100);
                        //alert('支付失败！');
                        $("#payMoney").text('确认支付').css('background', '#fc4208');
                        //alert(res.length);
//                        for (var i in res) {
//                            alert(i + '--' + res[i]);
//                        }

                        // 微信错误信息
                        /*
                        * res.err_code  错误码
                        * res.err_desc  错误描述
                        * res.err_msg   错误标识  支付是否请求成功
                        *
                        * */
                    }
                }
        );
    }

    function callpay()
    {
        if (typeof(WeixinJSBridge) == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        }else{
            jsApiCall();
        }
    }
</script>